package semant.second_pass;

import semant.Env;
import symbol.Symbol;
import symbol.ClassInfo;
import symbol.MethodInfo;
import syntaxtree.MainClass;
import syntaxtree.VisitorAdapter;

final class MainClassHandler extends VisitorAdapter {

    private Env env;

    private MainClassHandler(Env e){
	super();
	env = e;
    }

    static void secondPass(Env e, MainClass mc){
	MainClassHandler h = new MainClassHandler(e);
	mc.accept(h);
    }

    public void visit(MainClass node){
	ClassInfo cinfo = env.classes.get(Symbol.symbol(node.className.s));
	Symbol main = Symbol.symbol("main");
	MethodInfo minfo = new MethodInfo(null, main, cinfo.name);
	// classe principal tem apenas um statement
	StatementHandler.secondPass(env, cinfo, minfo, node.s);
    }

}
